import re
from scrapy import Request
from .base_spider import BaseSpider


class DazhongTourSpider(BaseSpider):
    name = "dazhong_tour"
    datas_xpath = "//div[@class='reviews-items']/ul/li"
    creator_xpath = "div//a[@class='name']/text()"
    content_xpath = "div//div[@class='review-truncated-words']/text()"
    create_date_xpath = "div//span[@class='time']/text()"
    create_date_pattern = "%Y-%m-%d %H:%M"

    def get_star(self, data):
        star = data.xpath("div//span[contains(@class,'star')]/@class").extract()[0]
        return re.findall("\\d+", star)[0]
